import Vue from 'vue'
import Router from 'vue-router'
import Register from "../views/register/register.vue"

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/login/login'), hidden: true},
  {path: '/register', component: () => import('@/views/register/register'), hidden: true},
  {path: '/404', component: () => import('@/views/404'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: 'fms',
    meta: {title: '首页', icon: 'home'}
  }
]

export const asyncRouterMap = [
  {
    path: '/',
    name: 'home',
    component: Layout,
    redirect: 'fms',
    alwaysShow: true,
    meta: {title: '首页', icon: 'home'}
  },
  {
    path: '/fms',
    name: 'fms',
    component: Layout,
    redirect: '/fms/film',
    meta: {title: '影片', icon: 'fms'},
    alwaysShow: true,
    children: [{
      path: 'film',
      name: 'film',
      component: () => import('@/views/film/index'),
      meta: {title: '影片展示', icon: 'film'},
    }, {
      path: 'maintenance',
      name: 'filmMaintenance',
      component: () => import('@/views/film/index'),
      meta: {title: '影片维护', icon: 'maintenance'},
    }, {
      path: 'rowPiece',
      name: 'filmRowPiece',
      component: () => import('@/views/film/index'),
      meta: {title: '排片', icon: 'row-piece'},
    }]
  },
  {
    path: '/cms',
    name: 'cms',
    component: Layout,
    redirect: '/cms/cinema',
    meta: {title: '影院', icon: 'cms'},
    alwaysShow: true,
    children: [{
      path: 'cinema',
      name: 'cinema',
      component: () => import('@/views/cinema/index'),
      meta: {title: '影院展示', icon: 'cinema'},
    }, {
      path: 'maintenance',
      name: 'cinemaMaintenance',
      component: () => import('@/views/cinema/index'),
      meta: {title: '影院维护', icon: 'maintenance'},
    }
    ]
  },
  {
    path: '/ums',
    component: Layout,
    redirect: '/ums/user',
    name: 'ums',
    meta: {title: '个人中心', icon: 'ums'},
    hidden: true,
    children: [
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/user/index'),
        meta: {title: '我的', icon: 'user'},
      },
      {
        path: 'login',
        name: 'login',
        component: () => import('@/views/login/login'),
        meta: {title: '登录', icon: 'login'},
      }, {
        path: 'register',
        name: 'register',
        component: () => import('@/views/register/register'),
        meta: {title: '注册', icon: 'register'},
      }
    ]
  },
  {
    path: '/oms',
    component: Layout,
    redirect: '/oms/ticket',
    name: 'oms',
    meta: {title: '收支统计', icon: 'oms'},
    alwaysShow: true,
    children: [
      {
        path: 'statistics',
        name: 'statistics',
        component: () => import('@/views/order/statistics'),
        hidden: true,
        meta: {title: '收益统计', icon: 'amount'},
      }, {
        path: 'ticket',
        name: 'ticket',
        component: () => import('@/views/order/ticket'),
        meta: {title: '票夹', icon: 'ticket'},
      }, {
        path: 'topUp',
        name: 'topUp',
        component: () => import('@/views/order/topUp'),
        meta: {title: '充值', icon: 'top-up'},
      }]
  },
  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

